package com.bigShen.mybatis.spring.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author : lei.shen
 * @date : 2018/12/20
 */
@Component
public class WebContextUtil implements ApplicationContextAware {

    public static ApplicationContext context;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }

    static <T> T getBean(Class<T> clazz) {
        return context.getBean(clazz);
    }

    static Object getBean(String beanName) {
        return context.getBean(beanName);
    }

}
